Technotes
A Technique for Estimating the Total RAM You Need for a QuickTime VR Project
Apple Developer Technical Support (DTS) When using the QTVR Authoring Tools to create a panorama, the most common problems arise from not having enough memory to accomplish the task. If you follow the recommendations in the QTVR Reference Manual, shooting with a 15mm lens and scanning your panoramas to PhotoCD and using the 768 x 512 resolution images, 40 MB of total RAM ought to be enough to get the job done.
But if, like some QTVR producers, you want to use higher resolution images or longer lenses for your project, you may need more RAM. This Technote, which is aimed at QTVR producers, will help you assess how much RAM you'll need and provide you with tips on how to recognize and avoid common memory-related problems.
A Method for Estimating the Minimum RAMMPW is by far the tool that needs the most RAM. Typically, a QTVR project requires that you allocate at least 30 MB to execute the QTVR tools that MPW calls, specifically stitch, which takes up the lion's share of memory. The other MPW tools, such as p2mv, are not significant in terms of the maximum or total amount of memory you need.p2mv (PICT to movie) is a tool that dices the panorama PICT which has been stitched into equally-sized tiles and then packages them as a QuickTime Movie. The msnm tool (make single node movie) takes the diced QuickTime Movie and adds the extra parameters that QuickTime VR needs to complete the panorama movie. The stitcher, running under MPW, requires enough RAM to buffer 3 copies of a panorama in order to stitch, rotate and crop the image. Because a panorama is technically a series of flat images wrapped into a cylinder, the surface of the cyclinder is what determines the amount of memory your project needs.
Steps To Estimate RAM RequirementsTo estimate roughly the minimum amount of RAM you'll need, follow these steps:
The FormulaHere are the factors you need to calculate the RAM requirements equation:
i (number of images with zero overlap to complete 360 degrees) b = 2 (number of buffers ) w = 1.44 (10% default work border) t=2 (number of temporary input images) h (horizontal input image resolution) v (vertical input image resolution) d = 4 (bit depth in bytes) k = 1024 (bytes per kilobyte) ((i*b*w) + t)*h*v*d/k = the KB RAM requirements
Two Sample CalculationsExample #1: If your 18mm lens in portrait format has about 65 of horizontal field of view, and you take 6 images to make a complete rotation, using the 768 x 512 resolution PhotoCD images, your cylinder size will be:
((6x2x1.44)+2)x768x512x4/1024 = 29614 KBTherefore, you'll need a minimum of 31 MB of RAM for MPW. Example #2: Using the standard QuickTake 150 digital camera in portrait mode requires a minimum of 14 images to complete a 360 degree panorama.
((14x2x1.44)+2)x640x480x4/1024 = 50784 KBThe irony is that the QuickTake camera, which is perceived as a lowend solution, actually requires more RAM than the 18mm SLR. However, if you use landscape mode with your QuickTake camera, the buffers will only need 38 MB.
Setting the MPW Memory PartitionYou can set MPW's Minimum and Preferred size in the Get Info dialog from the Finder.Unless you have lots of extra memory, you should quit all other applications before launching MPW. A typical Macintosh 7.5 System will need 5-10 MB of RAM -- more if you have extra extensions installed. If you install only a basic system, it's possible to reduce its memory needs to less than 5 MB. QuickTime loads into the system heap, so you need to make sure there is at least 1 MB for the system to grow when it loads QuickTime. Not having this freespace may cause unexpected errors. If you get errors while stitching, use About This Macintosh in the Apple menu to confirm that MPW has enough RAM and that there is still 1 MB of freespace. Calculating Total RAMAfter figuring the amount of RAM needed for MPW, add the following to your subtotal:
System (10 MB) + Freespace (1 MB) + MPW (RAM requirements) = Total RAM A Practical Configuration: A Personal ExampleMy camera system with an 18mm lens requires a minimum of 31+11 = 42 MB of RAM. Fortunately, I have 72 MB in my Power Macintosh 8100, and this allows me to stitch images captured with my second camera: the QuickTake 150. This also lets me run multiple tools concurrently, which saves me the time of relaunching whenever I change tasks.
Other Variables That Affect Memory RequirementsThese calculations should only be considered estimates. A number of other factors may cause the stitcher to require more memory in order to build a panorama. For example, a hand-held panorama often requires a larger image border to accomodate the "stairstepping" that occurs when the images are skewed and poorly aligned. To insure proper stitching, you may need to add another 20% memory to handle these worse-case situations.
Increasing or Reducing the Amount of RAMIf you want to increase or reduce the amount of RAM you need, there are three important variables you must take into account:
Memory Requirements for Other QTVR ToolsAlthough the QTVR dicer (the p2mv MPW tool) requires a lot of memory, it is always proportionally less than the stitcher.A common problem encountered by QTVR developers is not increasing the partition size of HyperCard to 20 MB required by the Scene Editor. Object movies require only as much RAM as needed for the Video Capture tools. Five megabytes of free space should be sufficient for most cases. Using Virtual MemoryIf you want to work with images requiring more RAM than you have, you can do so by turning on virtual memory. Virtual memory, however, really slows things down, often by as much as a factor of 10. But it may allow you to accomplish things that would otherwise require lots of expensive RAM. Plan on using virtual memory as an exception rather than the rule for your QTVR projects.
A Bench TestOne weekend I ran some timing tests, stitching large panoramas with virtual memory on. The reason I performed the tests was to see if I could push the limits of how large a panorama QuickTime VR could stitch.I used a Nikon N90, 18mm lens, Kaidan universal pan head to take 12 portrait shots per node. I shot the scene indoors with fluorescent lights. The negatives were scanned onto a PhotoCD and then stitched on a PowerPC 8100/80 with 72 MB of RAM. I ran a benchmark with virtual memory turned off, and then the others with virtual memory set to 480 MB! I stitched them first in an MPW partition that used all but 10 MB of free space. All Easy Install Macintosh 7.5.1 system extensions were enabled. For the largest size, I played it safe and turned off the -outWidth, -outHeight parameters and resized the panorama.srcPict with Adobe Photoshop. I thought I could dice it with less virtual memory, but eventually diced them all with 300MB of virtual memory. I wanted to use less than 480 MB because speed was a consideration.
Timing Results from the ExperimentTable 1 shows the timing results from the experiment. Note that all times are in Hours:Minutes:Seconds, rounded off.Table 1 Timing results with virtual memory on and off Resolu- tion VM stitch Time Output Size p2mv msnm 768 off 00:07:22 6.3 MB 0:01:58 0:00:03 192 on 00:01:00 0.416 MB 0:00:15 0:00:04 768 on 00:13:00 6.3 MB 0:07:30 0:00:20 1536 on 04:45:00 25 MB 0:47:20 0:00:45 3072 on 55:05:00 100 MB 3:00:00 0:02:00You can stitch 100MB panoramas if you have lots of time (as I did, for example -- 3 days!) The resulting movie I made was 8.7 MB, so it was not exactly practical for the World Wide Web and displayed about 2 frames/second on the PowerPC 8100, which was unacceptably choppy. If you have more time than money, it's possible to use virtual memory rather than add RAM and still build big panoramas, with lots of detail.
SummaryIt's possible to estimate your project's RAM requirements using the formula provided in this Technote. Note that these are minimum estimates. The most common problems are caused by not having enough RAM. The choice is clear: invest in the purchase of sufficient RAM to meet your QTVR development needs.
Technotes Previous Technote | Contents | Next Technote |